import { ref, getCurrentInstance } from "vue";
import { showSuccessToast, showFailToast, showToast } from "vant";
import clipboard3 from "vue-clipboard3";

export function useCopyLink() {
  const { $t } = getCurrentInstance().proxy;
  const { toClipboard } = clipboard3();
  const handCopy = async (link) => {
    try {
      await toClipboard(link);
      showToast($t("copysucc"));
    } catch (err) {
      showToast($t("copyFail"));
    }
  };

  return {
    handCopy,
  };
}
